package com.project.util;

import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//public class PressException {
//    @ExceptionHandler(Exception.class)
//    public String press(Exception e){
//        System.out.println("抛出"+e.getClass().getSimpleName()+"记录");
//        return "redirect:/error.html";//重定向。get请求要用 重定向
//    }
//}
/**
 * 处理未授权异常
 */
@RestControllerAdvice
public class PressException {
    @ExceptionHandler({AuthorizationException.class, UnauthorizedException.class})
    public String noPermission(){
        return "noPermission";
    }
    @ExceptionHandler(Exception.class)
    public String press(Exception e){
        System.out.println("抛出"+e.getClass().getSimpleName()+"记录");
        return "redirect:/system/login";//重定向。get请求要用 重定向
    }
}